package Cm818_Zj_Mi;

import DataAccess.*;

/** 
 NoWinManager ��ժҪ˵����
*/
public class NoWinManager
{
	public NoWinManager()
	{
	}
	/** 
	 
	 
	 @param ID ID
	 @param isLast �Ƿ��Ǹ�ע���һ�ζҽ�
	 @param HadEach �Ƿ��Ѿ��н�
	 @param Manager ������.
	 @return 
	*/
	public final boolean ToManager(int ID, boolean isLast, boolean HadEach, String Manager)
	{
		DaiGou dg = new DaiGou();
		dg.SelectByPk(ID);
		dg.setZt("δ�н�");
		dg.setZj("δ�н�");
		dg.setZj_Shijian(java.time.LocalDateTime.now().ToShortDateString());
		dg.setZj_Chuliren(Manager);
		if (isLast)
		{
			dg.setRnd("4");
		}
		if (HadEach)
		{
			dg.setZt("�Ѷҽ�");
			dg.setZj("���н�");
		}

		dg.Update();

		DaiGou dgaa = new DaiGou();
		dgaa.SelectByRndAndCac("1", dg.getCac(), dg.getNumber());

		String qihao = dgaa.getQiHao();



		DaiGouCollection cs = new DaiGouCollection();
		DaiGou dg2 = new DaiGou();
		if (dg2.SelectByRndAndCac("0", dg.getCac(), dg.getNumber()))
		{
			return true;
		}
//			if(!dg2.SelectByRndAndCac("1",dg.Cac))
//				return true;
		cs.ListAllNeedBackMoney(dg.getCac(), qihao);

		//�¼�
//			if(dg.zhuihao == "׷��")
//				cs.ListAllNeedBackMoneyIfZhuihao(dg.Cac,qihao);

		DataTable dtt = cs.getTable();

		for (int aa = 0;aa < dtt.Rows.size(); aa++)
		{
			int idd = Integer.parseInt(dtt.Rows[aa]["id"].toString());

			dg2.SelectByPk(idd);
			dg2.setRnd("0");
			dg2.Update();
		}


		return true;
	}

	public final boolean ToManager(int ID, boolean isLast, String Manager)
	{
		DaiGou dg = new DaiGou();
		dg.SelectByPk(ID);
		dg.setZt("δ�н�");
		dg.setZj("δ�н�");
		dg.setZj_Shijian(java.time.LocalDateTime.now().ToShortDateString());
		dg.setZj_Chuliren(Manager);

		dg.Update();


		return true;
	}


}